x86: Fix PoD cache size when decreasing memory
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 4 Sep 2009 07:43:05 +0000 (08:43 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 4 Sep 2009 07:43:05 +0000 (08:43 +0100)
Certain paths through p2m_pod_decrease_reservation() fail to reduce
the size of the PoD cache if the number of outstanding entries is less
than the size of the cache.  Rearrange so this doesn't happen.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
xen/arch/x86/mm/p2m.c

index c10b31b566498a54f4c480e9115636b768ef4cc3..511f35718f9df2fb0406d32d5a10e1c7aa33a880 100644 (file)
@@ -634,7 +634,7 @@ p2m_pod_decrease_reservation(struct domain *d,
         p2md->pod.entry_count-=(1<<order); /* Lock: p2m */
         BUG_ON(p2md->pod.entry_count < 0);
         ret = 1;
-        goto out_unlock;
+        goto out_entry_check;
     }
 
     /* FIXME: Steal contig 2-meg regions for cache */
@@ -678,6 +678,12 @@ p2m_pod_decrease_reservation(struct domain *d,
         }
     }    
 
+    /* If there are no more non-PoD entries, tell decrease_reservation() that
+     * there's nothing left to do. */
+    if ( nonpod == 0 )
+        ret = 1;
+
+out_entry_check:
     /* If we've reduced our "liabilities" beyond our "assets", free some */
     if ( p2md->pod.entry_count < p2md->pod.count )
     {
@@ -685,11 +691,6 @@ p2m_pod_decrease_reservation(struct domain *d,
         p2m_pod_set_cache_target(d, p2md->pod.entry_count);
     }
 
-    /* If there are no more non-PoD entries, tell decrease_reservation() that
-     * there's nothing left to do. */
-    if ( nonpod == 0 )
-        ret = 1;
-
 out_unlock:
     audit_p2m(d);
     p2m_unlock(p2md);